package logindb

import (
	"errors"
	"fmt"
	"myOJ/db"
)

func TakeAccount(name string) (int, string, string, error) {
	account, err := db.Dd.Query("SELECT * FROM accounts WHERE name='" + name + "'")
	if err != nil {
		fmt.Println("TakeAccount", err)
		return -1, "", "", errors.New("TakeAccount Error")
	} else {
		var id int
		var name, password string
		if account.Next() {
			account.Scan(&id, &name, &password)
			return id, name, password, nil
		}
		return -1, "", "", nil
	}
}
